<?php

namespace App\Enums\Message;

use App\Enums\CollectionPraisePvSceneEnum;
use App\Traits\EnumTrait;

class MessagePayloadBusinessSceneEnum
{
    use EnumTrait;

    const TECHNOLOGY = [
        'scene' => 1, 'text' => "技能", 'praiseScene' => CollectionPraisePvSceneEnum::TECHNOLOGY
    ];
    const COMMODITY = [
        'scene' => 2, 'text' => "宝物", 'praiseScene' => CollectionPraisePvSceneEnum::COMMODITY
    ];
    const MOMENT = [
        'scene' => 3, 'text' => "时光", 'praiseScene' => CollectionPraisePvSceneEnum::MOMENT
    ];
    const COMMENT = [
        'scene' => 4, 'text' => "评论", 'praiseScene' => CollectionPraisePvSceneEnum::COMMENT
    ];
    const REPLY = [
        'scene' => 5, 'text' => "留言", 'praiseScene' => CollectionPraisePvSceneEnum::REPLY
    ];
    const ORDER = [
        'scene' => 6, 'text' => "订单", 'praiseScene' => null
    ];
    const PRAISE = [
        'scene' => 7, 'text' => "点赞"
    ];
    const SUBSCRIBE = [
        'scene' => 8, 'text' => "关注"
    ];

    public static function getScene($data)
    {
        return $data['scene'];
    }

    public static function getText($data)
    {
        return $data['text'];
    }

    /**
     * 根据点赞场景获取当前场景
     * @param $praiseScene
     * @return int|mixed
     */
    public static function getSceneByPraiseScene($praiseScene)
    {
        foreach (self::getConstants() as $constant) {
            if ($constant['praiseScene'] == $praiseScene) {
                return $constant['scene'];
            }
        }
        return 0;
    }
}
